package cz.proks.easyhelpdesk.gwt.event;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.user.client.ui.Label;

public class LabelChangeEvent extends GwtEvent<LabelChangeEvent.Handler>{
    public final static Type<Handler> TYPE = new Type<LabelChangeEvent.Handler>();    
    
    public static interface Handler extends EventHandler {
        void onLabelChange(LabelChangeEvent event);
    }
    
    private final Label label;
    
    public LabelChangeEvent(Label label) {
        this.label = label;
    }
    
    public Label getNewLabel() {
        return label;
    }

    public static void fireEvent(HasLabelChangeHandlers source, Label newLabel) {
        source.fireEvent(new LabelChangeEvent(newLabel));
    }
    
    @Override
    public com.google.gwt.event.shared.GwtEvent.Type<Handler> getAssociatedType() {
        return TYPE;
    }

    @Override
    protected void dispatch(Handler handler) {
        handler.onLabelChange(this);
    }    
}
